﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XMLSpreadGear.Core;

namespace XMLSpreadGear.Headers
{
    public class Style:MultiElement<Style>
    {
        private string sID;

        public string ID
        {
            get { return sID; }
            set { sID = value; }
        }
        private string sName;

        public string Name
        {
            get { return sName; }
            set { sName = value; }
        }

        private StyleAlignment sAlignment;
        
        public StyleAlignment Alignment
        {
            get { return sAlignment; }
            set { sAlignment = value; }
        }
        private Borders bBorders;

        public Borders Borders
        {
            get { return bBorders; }
            set { bBorders = value; }
        }
        private Font fFont;

        public Font Font
        {
            get { return fFont; }
            set { fFont = value; }
        }
        private Interior iInterior;

        public Interior Interior
        {
            get { return iInterior; }
            set { iInterior = value; }
        }
        private NumberFormat nfNumberFormat;

        public NumberFormat NumberFormat
        {
            get { return nfNumberFormat; }
            set { nfNumberFormat = value; }
        }
        private Protection pProtection;

        public Protection Protection
        {
            get { return pProtection; }
            set { pProtection = value; }
        }

        public Style(string id)
            : base(LocalNames.STYLE)
        {
            this.sID = id;
        }

        public Style(StyleAlignment sAlignment, Borders Borders, Font font,
            Interior interior, NumberFormat numberFormat, Protection protection,string Id, string name)
            : this(Id)
        {
            this.sAlignment = sAlignment;
            this.bBorders = Borders;
            this.fFont = font;
            this.iInterior = interior;
            this.nfNumberFormat = numberFormat;
            this.pProtection = protection;
            this.sName = name;
        }

        internal protected override IDictionary<string, string> RegisterElements()
        {
            IDictionary<string, string> dic = new Dictionary<string, string>();
            if(this.Alignment != null)
                dic.Add("Alignment", this.Alignment.ToString());

            if(this.Borders != null)
                dic.Add("Borders", this.Borders.ToString());

            if(this.Font != null)
                dic.Add("Font", this.Font.ToString());

            if(this.Interior != null)
                dic.Add("Interior", this.Interior.ToString());

            if(this.NumberFormat != null)
                dic.Add("NumberFormat", this.NumberFormat.ToString());

            if(this.Protection != null)
                dic.Add("Protection", this.Protection.ToString());

            return dic;
        }

        internal protected override IDictionary<string, string> RegisterAttributes()
        {
            IDictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("ID", this.ID);

            if(!string.IsNullOrEmpty(this.Name))
                dic.Add("Name", this.Name);

            return dic;
        }

        internal override string GetAttributeNamespace()
        {
            return Contstants.SpredsheetAttributePrefix;
        }

        internal override string GetAttributeNamespaceURI()
        {
            return Contstants.SpredsheetAttributeNamespace;
        }
    }
}
